package unit13;
import java.util.*;
public class TreeSetTest {
	public static void main(String[] args) {
		SortedSet<Item> parts=new TreeSet<>();
		parts.add(new Item("Toaster", 1234));
		parts.add(new Item("Alice", 2345));
		parts.add(new Item("Mike", 3456));
		parts.add(new Item("Tom", 4567));
		parts.add(new Item("Ben", 5678));
		
		SortedSet<Item> sortByDescription=new TreeSet<>(new Comparator<Item>() {

			@Override
			public int compare(Item o1, Item o2) {
				// TODO Auto-generated method stub
				String descrA=o1.getDescription();
				String descrB=o2.getDescription();
				return descrA.compareTo(descrB);
			}
		});
		sortByDescription.addAll(parts);
		for(Item I:sortByDescription)
		System.out.println(I);
	}
}
